export default [
  {
    url: "/api/login",
    method: "post",
    response: ({ body }) => {
      // 模拟用户数据
      const users = [
        {
          username: "admin",
          password: "123456",
          token: "admin-token",
          role: "admin",
          avatar: "https://avatars.githubusercontent.com/u/1234567?v=4",
        },
        {
          username: "user",
          password: "123456",
          token: "user-token",
          role: "user",
          avatar: "https://avatars.githubusercontent.com/u/7654321?v=4",
        },
      ];

      const user = users.find(
        (user) =>
          user.username === body.username && user.password === body.password
      );

      if (!user) {
        return {
          code: 401,
          message: "用户名或密码错误",
          data: null,
        };
      }

      return {
        code: 200,
        message: "登录成功",
        data: {
          token: user.token,
          userInfo: {
            username: user.username,
            role: user.role,
            avatar: user.avatar,
          },
        },
      };
    },
  },
];
